package com.qzimp.fujiancuo.entity;

import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 *  实体类。
 *
 * @author 吴宗波
 * @since 2024-11-21
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("")
@Table(value = "tb_event")
public class Event implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id(keyType = KeyType.Auto)
    @ApiModelProperty("")
    private Integer id;

    @ApiModelProperty("")
    private String name;

    @ApiModelProperty("")
    private LocalDateTime happenTime;

    @ApiModelProperty("")
    private String description;

    @ApiModelProperty("")
    private Integer cuoId;

    public void setHappenTime(String happenTime) {
        // 处理只包含日期部分的字符串，防止重复的 "T00:00:00"
        if (happenTime != null && !happenTime.isEmpty()) {
            if (happenTime.length() == 10) {  // 只包含日期部分
                // 将字符串格式化为 LocalDateTime，手动补充 "T00:00:00"
                happenTime = happenTime + "T00:00:00";
            }
            DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
            this.happenTime = LocalDateTime.parse(happenTime, formatter);
        }
    }


}
